import React, { Component, Fragment } from 'react'
import {OneDiv} from "../../styled/index"
import {connect} from "react-redux"
 class onediv extends Component {
    constructor(props){
        super(props)
        this.state={
            totalEssay:""
        }
    }
    componentDidMount(){
        console.log(this.props)
        console.log(this.props.state.textReducer)
    }
    dataDiv=()=>{
        console.log(this.props.state.textReducer)
        return this.props.state.textReducer.state.map((item,index)=>{
            return (
                <Fragment key={index}>
                        <img src={item.mainImg} alt="加载错误"/>
                    <div className="data_wrap">
                        <span>TO REAO</span>
                        <p className="title">{item.title}</p>
                        <p className="fu_title">{item.fu_title}</p>
                        <hr/>
                        <p className="autor">{item.autor}</p>
                    </div>
                    <footer>
                        <p>评论 <span>{item.comment_num}</span></p>
                        <p>喜欢 <span>{item.like_num}</span></p>
                        <p>阅读数 <span>{item.read_num}</span></p>
                    </footer>
                </Fragment>
            )
        })
    }
    render() {
        return (

            <OneDiv>
                <p>{this.props.state.textReducer?this.dataDiv():"null"}</p>
                
            </OneDiv>
        )
    }
}
export default connect((state)=>({state}))(onediv)
